Option Explicit On 

Public Class frmStatus
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents txtMsg As System.Windows.Forms.Label
    Friend WithEvents pBar As System.Windows.Forms.ProgressBar
    Friend WithEvents tmr As System.Windows.Forms.Timer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.txtMsg = New System.Windows.Forms.Label
        Me.pBar = New System.Windows.Forms.ProgressBar
        Me.tmr = New System.Windows.Forms.Timer(Me.components)
        Me.SuspendLayout()
        '
        'txtMsg
        '
        Me.txtMsg.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtMsg.Font = New System.Drawing.Font("Courier New", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtMsg.Location = New System.Drawing.Point(18, 18)
        Me.txtMsg.Name = "txtMsg"
        Me.txtMsg.Size = New System.Drawing.Size(380, 144)
        Me.txtMsg.TabIndex = 0
        Me.txtMsg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'pBar
        '
        Me.pBar.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.pBar.Location = New System.Drawing.Point(18, 174)
        Me.pBar.Name = "pBar"
        Me.pBar.Size = New System.Drawing.Size(380, 34)
        Me.pBar.TabIndex = 1
        '
        'tmr
        '
        Me.tmr.Enabled = True
        '
        'frmStatus
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
        Me.ClientSize = New System.Drawing.Size(416, 230)
        Me.Controls.Add(Me.pBar)
        Me.Controls.Add(Me.txtMsg)
        Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
        Me.Name = "frmStatus"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Const WIN_FORM_OPACITY As Integer = 100
    Private Const TIMER_INTERVAL As Integer = 50
    Private _opacityIncrease As Double = 0.5
    Private _opacityDecrease As Double = 0.2


    Public Overloads Sub Show(ByVal _message As String, ByVal _title As String)
        Me.Text = _title
        txtMsg.Text = _message

        Me.Opacity = _opacityIncrease
        Me.tmr.Interval = TIMER_INTERVAL
        Me.tmr.Start()

        Me.TopMost = True
        Me.ShowInTaskbar = False
        Me.Show()
    End Sub


    Public Overloads Sub Close(ByVal _closeMsg As String)
        Me._opacityIncrease = -Me._opacityDecrease
    End Sub


    Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick

        If _opacityIncrease > 0 Then

            '   increase
            If Me.Opacity < 1 Then
                Me.Opacity += _opacityIncrease
            Else
                If Me.Opacity > 0 Then
                    Me.Opacity += _opacityIncrease
                Else
                    Me.tmr.Stop()
                End If
            End If

        Else
            '   decrease
            If Me.Opacity > 0 Then
                Me.Opacity -= _opacityDecrease
            Else
                Me.Close()
            End If
        End If

    End Sub
End Class
